#include <stdio.h>
void print(int bColor,char* pStr);
int printf(const char *fmt, ...);

typedef struct
{
    struct
    {
        long l,h;
    } base, size;
    long type;
}SMAP;

int printf(const char *fmt, ...)
{
    char strbuf[512];
    int result;
    va_list ap;

    va_start(ap, fmt);
    result = vsprintf(strbuf,fmt, ap);
    va_end(ap);
    print(7,strbuf);
    return result;
}

void halt()
{
    asm hlt;
}

int cstart()
{
    int i;
    char w[]="World";
    printf("neocs: loader v%d.%d\n\r",1,1);
    printf("Hello world\n\rHello %s!!\n\r",&w[0]);

    halt();
    return 0;
}

void print(int bColor,char* pStr)
{
    asm push bx;
    asm push si;
    asm mov si, pStr;
    asm mov bx, bColor;
    asm xor bh, bh;
    loop:
    asm mov ah, 0eh;
    asm mov al, [ds:si];
    asm cmp al, 0;
    asm jz ret;
    asm int 010h;
    asm inc si;
    asm jmp loop;
    ret:
    asm pop si;
    asm pop bx;
}
